﻿var opt = {
    onOpen: function (dialog) {
        dialog.container.width(260);
        callback.slideDownToOpen(dialog, "slow");
    },
    onClose: function (dialog) { callback.slideUpToClose(dialog, "slow"); },
    minHeight: 121
};

var editproduct = {
    init: function () {
        $("#myuploadimage").hide();
        $("#myviewimage").hide();
        if ($('#<%= lbImage.ClientID %>').val().length == 0) {
            $("#aViewImage").hide();
        }
    }
};

$(document).ready(function () {
    editproduct.init();
    if ($('#<%= lbImage.ClientID %>').text().trim().length > 0) {
        $('#aViewImage').show();
    }

    $("#aUpImage").bind("click", function () {
        $("#myuploadimage").modal(opt);
    });

    $("#aViewImage").bind("click", function () {
        $("#myviewimage").modal(opt);
    });

    $("#btUpLoad").bind("click", function () {
        var name = $('#<%= upFile.ClientID %>').val();
        $.modal.close("#myuploadimage");
        if (name.length > 0) {
            $('#aViewImage').show("normal", function () { $('#<%= lbImage.ClientID %>').val(name); });
        }

    });


    $('#<%= upFile.ClientID %>').change(function (e) {
        //                for (var i = 0; i < e.originalEvent.srcElement.files.length; i++) {
        //                    var file = e.originalEvent.srcElement.files[i];

        //                    var img = document.createElement("viewImage");
        //                    var reader = new FileReader();
        //                    reader.onloadend = function () {
        //                        img.src = reader.result;
        //                    }
        //                    reader.readAsDataURL(file);
        //                }
    });

});
